package cn.iocoder.yudao.module.biz.dal.mysql.contract.autocode;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.biz.controller.admin.contract.autocode.part.vo.AutoCodePartPageReqVO;
import cn.iocoder.yudao.module.biz.dal.dataobject.contract.autocode.AutoCodePartDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 编码生成规则组成 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface AutoCodePartMapper extends BaseMapperX<AutoCodePartDO> {
    default PageResult<AutoCodePartDO> selectPage(AutoCodePartPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AutoCodePartDO>()
                .eqIfPresent(AutoCodePartDO::getRuleId, reqVO.getRuleId())
                .eqIfPresent(AutoCodePartDO::getPartIndex, reqVO.getPartIndex())
                .likeIfPresent(AutoCodePartDO::getPartName, reqVO.getPartName())
                .eqIfPresent(AutoCodePartDO::getPartLength, reqVO.getPartLength())
                .eqIfPresent(AutoCodePartDO::getPartType, reqVO.getPartType())
                .eqIfPresent(AutoCodePartDO::getFixedCharacter, reqVO.getFixedCharacter())
                .eqIfPresent(AutoCodePartDO::getDateFormat, reqVO.getDateFormat())
                .eqIfPresent(AutoCodePartDO::getSeriaStartNo, reqVO.getSeriaStartNo())
                .eqIfPresent(AutoCodePartDO::getSeriaStep, reqVO.getSeriaStep())
                .eqIfPresent(AutoCodePartDO::getCycleFlag, reqVO.getCycleFlag())
                .eqIfPresent(AutoCodePartDO::getCycleMethod, reqVO.getCycleMethod())
                .eqIfPresent(AutoCodePartDO::getCreateDept, reqVO.getCreateDept())
                .betweenIfPresent(AutoCodePartDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(AutoCodePartDO::getRemark, reqVO.getRemark())
                .orderByDesc(AutoCodePartDO::getPartId));
    }
}